{% extends "menu.html" %}
{% block content %}

        <!-- page content -->
        <div class="right_col" role="main">
          <div class="">
            <div class="page-title">



            </div>
            <div class="clearfix"></div>
            <div class="row">
              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  <div class="x_title">
                    <h2>新增SaltStackServer</h2>

                    <div class="clearfix"></div>
                  </div>
                  <div class="x_content">
                    <br />
                    <form id="demo-form2" data-parsley-validate class="form-horizontal form-label-left" method="post">
                        {% csrf_token %}
                      <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name"> SaltStack Server IP<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input type="text" id="first-name" required="required" class="form-control col-md-7 col-xs-12" name="s_ip">
                        </div>
                      </div>
                      <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name"> SaltStack Server Name<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input type="text" id="first-name" required="required" class="form-control col-md-7 col-xs-12" name="s_name" placeholder="命名规则是必须以字母组合">
                        </div>
                      </div>
                      <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name"> 登录方式<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <p style="margin-top: 6px">密码登录：<input type="radio" name="login_mode" value="1" checked> key登录： <input type="radio" name="login_mode" value="2"></p>
                        </div>
                      </div>
                      <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name"> SaltStack Server Version<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                           <input type="text" id="first-name" required="required" class="form-control col-md-7 col-xs-12" name="s_version" placeholder="https://repo.saltstack.com/yum/redhat/salt-repo-2018.3.el7.noarch.rpm ">
                        </div>
                      </div>
                      <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">gitlab<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                           <input type="text" id="first-name" required="required" class="form-control col-md-7 col-xs-12" name="gitlab" placeholder="git@gitlab.tckej.com:root/devops.git">
                        </div>
                      </div>
                      <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">file_roots<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                           <input type="text" id="first-name" required="required" class="form-control col-md-7 col-xs-12" name="file_roots" placeholder="/srv/">
                        </div>
                      </div>
                      <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">pillar_roots<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                           <input type="text" id="first-name" required="required" class="form-control col-md-7 col-xs-12" name="pillar_roots" placeholder="/srv/">
                        </div>
                      </div>

                      <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name"> cmd<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <select style="width: 60%;height:auto;font-size: 15px" size="10" name="s_cmd"  multiple>
                              {% for cmd in cmd_list %}
                              <option value="{{ cmd.id }}">{{ cmd.cmd_command }}</option>
                              {% endfor %}
                          </select>
                        </div>
                      </div>
                    <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name"> 提示<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          1、设置的file_roots 和pillar_roots 需要是相同上级目录<br>
                            2、获取最新代码会自动覆盖到指定的顶级目录下，git代码库中的结构需要是salt 和pillar目录<br>
                            3、需要手动配置/etc/salt/master 配置文件<br>
                            4、需要手动启动salt-master服务<br>
                            5、默认salt server 不支持自动认证
                        </div>
                      </div>

                        <div class="form-group">
                        <label for="middle-name" class="control-label col-md-3 col-sm-3 col-xs-12"></label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <span>{{ result }}</span>
                        </div>
                      </div>
                      <div class="ln_solid"></div>
                      <div class="form-group">
                        <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
                          <button class="btn btn-primary" type="button">Cancel</button>
						  <button class="btn btn-primary" type="reset">Reset</button>
                          <button type="submit" class="btn btn-success">Submit</button>
                        </div>
                      </div>

                    </form>
                  </div>
                </div>
                  <div class="x_panel">
                  <div class="x_title">
                    <h2>SaltStackServer列表</h2>

                    <div class="clearfix"></div>
                  </div>
                  <div class="x_content">
                    <br />
                    <table class="sui-table table-bordered">
                          <thead>
                            <tr>
                                <th>ID</th>
                                <th>Server</th>
                                <th>IP</th>
                                <th>Version</th>
                                <th>Gitlab</th>
                                <th>管理 </th>


                            </tr>
                          </thead>
                          <tbody>
                          <style type="text/css">
                             tr:hover{
                                 background-color: #FFFFE0;
                             }
                          </style>
                          {% for i in salt_list %}
                            <tr>

                                <td>{{ i.id}}</td>
                                <td>{{ i.s_name }}</td>
                                <td>{{ i.s_ip }} </td>
                                <td>{{ i.s_version }}</td>
                                <td>{{ i.s_gitlab }}</td>
                                {% if i.s_init == "0" %}
                                    <td><a href="/saltconfig/codeinit/?id={{ i.id}}" ><span class="label label-info">初始化</span></a>&nbsp;&nbsp;<a href="/saltconfig/del/?id={{ i.id}}" ><span class="label label-danger">删除</span></a></td>

                                {% else %}
                                <td><a href="/saltconfig/admin/?id={{ i.id}}"><span class="label label-info">salt管理</span></a>  <a href="/saltconfig/codeupdate/?id={{ i.id}}" ><span class="label label-info">获取最新代码</span></a>&nbsp;&nbsp;<a href="/saltconfig/del/?id={{ i.id}}" ><span class="label label-danger">删除</span></a></td>
                                {% endif %}
                            </tr>
                        {% endfor %}
                          </tbody>
                      </table>
                  </div>
                </div>
              </div>
            </div>


          </div>
        </div>
{% endblock %}